package com.scau.ums.service.factory;

import com.scau.ums.model.User;
import com.scau.ums.service.CommonSuggest;
import com.scau.ums.service.imp.suggest.AdminSuggestImp;
import com.scau.ums.service.imp.suggest.MaintainerSuggestImp;
import com.scau.ums.service.imp.suggest.StudentSuggestImp;
import com.scau.ums.service.imp.suggest.TeacherSuggestImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * author: 莫伟杰
 * date： 2019/7/23 15:09
 */
@Component
public class SuggestImpFactory {
    private AdminSuggestImp adminSuggestImp;
    private StudentSuggestImp studentSuggestImp;
    private TeacherSuggestImp teacherSuggestImp;
    private MaintainerSuggestImp maintainerSuggestImp;

    @Autowired
    public SuggestImpFactory(AdminSuggestImp adminSuggestImp, StudentSuggestImp studentSuggestImp, TeacherSuggestImp teacherSuggestImp, MaintainerSuggestImp maintainerSuggestImp) {
        this.adminSuggestImp = adminSuggestImp;
        this.studentSuggestImp = studentSuggestImp;
        this.teacherSuggestImp = teacherSuggestImp;
        this.maintainerSuggestImp = maintainerSuggestImp;
    }

    //根据类型返回对应的接口实现类
    public CommonSuggest getSuggestImp(int Type)
    {
        switch (Type)
        {
            case User.ADMIN:return adminSuggestImp;
            case User.STUDENT:return studentSuggestImp;
            case User.TEACHER:return teacherSuggestImp;
            case User.MAINTAINER:return maintainerSuggestImp;
            default:return null;
        }
    }
}
